package com.eightbears.beboy.entity;

import com.eightbears.beboy.base.BaseEntity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class HomeListEntity extends BaseEntity implements Serializable {

    private PostListData data;

    public PostListData getData() {
        return data;
    }

    public void setData(PostListData data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "HomeListEntity{" +
                "data=" + data +
                '}';
    }

    public static class PostListData implements Serializable {

        private int next_page;
        private int page_size;
        private int is_end;
        private int free_key;
        private List<Post> list;

        public int getNext_page() {
            return next_page;
        }

        public void setNext_page(int next_page) {
            this.next_page = next_page;
        }

        public int getPage_size() {
            return page_size;
        }

        public void setPage_size(int page_size) {
            this.page_size = page_size;
        }

        public int getIs_end() {
            return is_end;
        }

        public void setIs_end(int is_end) {
            this.is_end = is_end;
        }

        public int getFree_key() {
            return free_key;
        }

        public void setFree_key(int free_key) {
            this.free_key = free_key;
        }

        public List<Post> getList() {
            return list;
        }

        public void setList(List<Post> list) {
            this.list = list;
        }

        @Override
        public String toString() {
            return "PostListData{" +
                    "next_page=" + next_page +
                    ", page_size=" + page_size +
                    ", is_end=" + is_end +
                    ", free_key=" + free_key +
                    ", list=" + list +
                    '}';
        }
    }

    public static class Post implements Serializable {

        private String id;                 // 帖子id
        private String user_id;            // 发帖用户id
        private String category;
        private String post;            // 帖子内容
        private List<String> images;    // 帖子图片
        private int status;
        private double price;           // 价格 0为免费
        private boolean setShrink;
        private int repost_id;          // 转帖id
        private String province_id;
        private String city_id;
        private String district_id;
        private String consumed_at;
        private String shop;
        private String address;
        private String longitude;
        private String latitude;
        private String contact;
        private String consumption;
        private String posted_at;
        private String created_at;      // 发帖时间
        private String updated_at;      // 更新时间
        private int is_follow;          // 是否收藏
        private PostUser user;
        private Repost repost;
        private List<Purchase> purchase;
        private List<RepostPurchase> repost_purchase;
        private Statistic statistic;
        private int fav;                // 0没有收藏，1收藏
        private int praise;             // 0没有点赞，1点赞
        private boolean isReport;
        private boolean isHeadTitle;
        private Points points;

        public Points getPoints() {
            return points;
        }

        public void setPoints(Points points) {
            this.points = points;
        }

        public boolean isHeadTitle() {
            return isHeadTitle;
        }

        public void setHeadTitle(boolean headTitle) {
            isHeadTitle = headTitle;
        }

        public boolean isReport() {
            return isReport;
        }

        public void setReport(boolean report) {
            isReport = report;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getUser_id() {
            return user_id;
        }

        public void setUser_id(String user_id) {
            this.user_id = user_id;
        }

        public String getCategory() {
            return category;
        }

        public void setCategory(String category) {
            this.category = category;
        }

        public String getPost() {
            return post;
        }

        public void setPost(String post) {
            this.post = post;
        }

        public List<String> getImages() {
            return images;
        }

        public void setImages(List<String> images) {
            this.images = images;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public double getPrice() {
            return price;
        }

        public void setPrice(double price) {
            this.price = price;
        }

        public int getRepost_id() {
            return repost_id;
        }

        public void setRepost_id(int repost_id) {
            this.repost_id = repost_id;
        }

        public String getProvince_id() {
            return province_id;
        }

        public void setProvince_id(String province_id) {
            this.province_id = province_id;
        }

        public String getCity_id() {
            return city_id;
        }

        public void setCity_id(String city_id) {
            this.city_id = city_id;
        }

        public String getDistrict_id() {
            return district_id;
        }

        public void setDistrict_id(String district_id) {
            this.district_id = district_id;
        }

        public String getConsumed_at() {
            return consumed_at;
        }

        public void setConsumed_at(String consumed_at) {
            this.consumed_at = consumed_at;
        }

        public String getShop() {
            return shop;
        }

        public void setShop(String shop) {
            this.shop = shop;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public String getLongitude() {
            return longitude;
        }

        public void setLongitude(String longitude) {
            this.longitude = longitude;
        }

        public String getLatitude() {
            return latitude;
        }

        public void setLatitude(String latitude) {
            this.latitude = latitude;
        }

        public String getContact() {
            return contact;
        }

        public void setContact(String contact) {
            this.contact = contact;
        }

        public String getConsumption() {
            return consumption;
        }

        public void setConsumption(String consumption) {
            this.consumption = consumption;
        }

        public String getPosted_at() {
            return posted_at;
        }

        public void setPosted_at(String posted_at) {
            this.posted_at = posted_at;
        }

        public String getCreated_at() {
            return created_at;
        }

        public void setCreated_at(String created_at) {
            this.created_at = created_at;
        }

        public String getUpdated_at() {
            return updated_at;
        }

        public void setUpdated_at(String updated_at) {
            this.updated_at = updated_at;
        }

        public int getIs_follow() {
            return is_follow;
        }

        public void setIs_follow(int is_follow) {
            this.is_follow = is_follow;
        }

        public PostUser getUser() {
            return user;
        }

        public void setUser(PostUser user) {
            this.user = user;
        }

        public Repost getRepost() {
            return repost;
        }

        public void setRepost(Repost repost) {
            this.repost = repost;
        }

        public List<Purchase> getPurchase() {
            return purchase;
        }

        public void setPurchase(List<Purchase> purchase) {
            this.purchase = purchase;
        }

        public List<RepostPurchase> getRepost_purchase() {
            return repost_purchase;
        }

        public void setRepost_purchase(List<RepostPurchase> repost_purchase) {
            this.repost_purchase = repost_purchase;
        }

        public static class Points implements Serializable {
            private int point;
            private int total_point;
            private int level;
            private int point_to_next;

            public int getPoint() {
                return point;
            }

            public void setPoint(int point) {
                this.point = point;
            }

            public int getTotal_point() {
                return total_point;
            }

            public void setTotal_point(int total_point) {
                this.total_point = total_point;
            }

            public int getLevel() {
                return level;
            }

            public void setLevel(int level) {
                this.level = level;
            }

            public int getPoint_to_next() {
                return point_to_next;
            }

            public void setPoint_to_next(int point_to_next) {
                this.point_to_next = point_to_next;
            }
        }

        public Statistic getStatistic() {
            return statistic;
        }

        public void setStatistic(Statistic statistic) {
            this.statistic = statistic;
        }

        public int getFav() {
            return fav;
        }

        public void setFav(int fav) {
            this.fav = fav;
        }

        public int getPraise() {
            return praise;
        }

        public void setPraise(int praise) {
            this.praise = praise;
        }

        public boolean isSetShrink() {
            return setShrink;
        }

        public void setSetShrink(boolean setShrink) {
            this.setShrink = setShrink;
        }

        public void executeLike() {
            if (getPraise() == 1) {
                subLike();
                setPraise(0);
            } else {
                addLike();
                setPraise(1);
            }
        }

        public void addLike() {
            int newLike = Integer.parseInt(getStatistic().getPraise());
            getStatistic().setPraise((newLike + 1) + "");
        }

        public void subLike() {
            int newLike = Integer.parseInt(getStatistic().getPraise());
            getStatistic().setPraise((newLike - 1) + "");
        }

        public void buyPost() {
            Purchase purchase = new Purchase();
            purchase.setCreated_at(getCreated_at());
            purchase.setUser_id(getUser_id());
            purchase.setId(getId());
            List<Purchase> purchases = new ArrayList<>();
            purchases.add(purchase);
            setPurchase(purchases);
        }

        @Override
        public String toString() {
            return "PostList{" +
                    "id='" + id + '\'' +
                    ", user_id='" + user_id + '\'' +
                    ", category='" + category + '\'' +
                    ", post='" + post + '\'' +
                    ", images=" + images +
                    ", status=" + status +
                    ", price=" + price +
                    ", repost_id='" + repost_id + '\'' +
                    ", province_id='" + province_id + '\'' +
                    ", city_id='" + city_id + '\'' +
                    ", district_id='" + district_id + '\'' +
                    ", consumed_at='" + consumed_at + '\'' +
                    ", shop='" + shop + '\'' +
                    ", address='" + address + '\'' +
                    ", longitude='" + longitude + '\'' +
                    ", latitude='" + latitude + '\'' +
                    ", contact='" + contact + '\'' +
                    ", consumption='" + consumption + '\'' +
                    ", posted_at='" + posted_at + '\'' +
                    ", created_at='" + created_at + '\'' +
                    ", updated_at='" + updated_at + '\'' +
                    ", is_follow=" + is_follow +
                    ", user=" + user +
                    ", repost=" + repost +
                    ", purchase=" + purchase +
                    ", repost_purchase=" + repost_purchase +
                    ", statistic=" + statistic +
                    ", fav=" + fav +
                    ", praise=" + praise +
                    '}';
        }
    }

    public static class PostUser implements Serializable {

        private String user_id;
        private String nickname;
        private String cover;
        private int vip_level;

        public String getUser_id() {
            return user_id;
        }

        public void setUser_id(String user_id) {
            this.user_id = user_id;
        }

        public String getNickname() {
            return nickname;
        }

        public void setNickname(String nickname) {
            this.nickname = nickname;
        }

        public String getCover() {
            return cover;
        }

        public void setCover(String cover) {
            this.cover = cover;
        }

        public int getVip_level() {
            return vip_level;
        }

        public void setVip_level(int vip_level) {
            this.vip_level = vip_level;
        }

        @Override
        public String toString() {
            return "PostUser{" +
                    "user_id='" + user_id + '\'' +
                    ", nickname='" + nickname + '\'' +
                    ", cover='" + cover + '\'' +
                    ", vip_level=" + vip_level +
                    '}';
        }
    }

    public static class Repost implements Serializable {

        private String id;
        private String user_id;
        private String post;
        private List<String> images;
        private int status;
        private double price;
        private String repost_id;
        private String consumed_at;
        private String shop;
        private String address;
        private String longitude;
        private String latitude;
        private String contact;
        private String consumption;
        private String created_at;
        private String updated_at;
        private String nickname;
        private String cover;


        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getUser_id() {
            return user_id;
        }

        public void setUser_id(String user_id) {
            this.user_id = user_id;
        }

        public String getRepost_id() {
            return repost_id;
        }

        public void setRepost_id(String repost_id) {
            this.repost_id = repost_id;
        }

        public String getPost() {
            return post;
        }

        public void setPost(String post) {
            this.post = post;
        }

        public List<String> getImages() {
            return images;
        }

        public void setImages(List<String> images) {
            this.images = images;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public double getPrice() {
            return price;
        }

        public void setPrice(double price) {
            this.price = price;
        }

        public String getConsumed_at() {
            return consumed_at;
        }

        public void setConsumed_at(String consumed_at) {
            this.consumed_at = consumed_at;
        }

        public String getShop() {
            return shop;
        }

        public void setShop(String shop) {
            this.shop = shop;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public String getLongitude() {
            return longitude;
        }

        public void setLongitude(String longitude) {
            this.longitude = longitude;
        }

        public String getLatitude() {
            return latitude;
        }

        public void setLatitude(String latitude) {
            this.latitude = latitude;
        }

        public String getContact() {
            return contact;
        }

        public void setContact(String contact) {
            this.contact = contact;
        }

        public String getConsumption() {
            return consumption;
        }

        public void setConsumption(String consumption) {
            this.consumption = consumption;
        }

        public String getCreated_at() {
            return created_at;
        }

        public void setCreated_at(String created_at) {
            this.created_at = created_at;
        }

        public String getUpdated_at() {
            return updated_at;
        }

        public void setUpdated_at(String updated_at) {
            this.updated_at = updated_at;
        }

        public String getNickname() {
            return nickname;
        }

        public void setNickname(String nickname) {
            this.nickname = nickname;
        }

        public String getCover() {
            return cover;
        }

        public void setCover(String cover) {
            this.cover = cover;
        }


        @Override
        public String toString() {
            return "Repost{" +
                    "id=" + id +
                    ", user_id=" + user_id +
                    ", post='" + post + '\'' +
                    ", images=" + images +
                    ", status=" + status +
                    ", price=" + price +
                    ", repost_id=" + repost_id +
                    ", consumed_at='" + consumed_at + '\'' +
                    ", shop='" + shop + '\'' +
                    ", address='" + address + '\'' +
                    ", longitude='" + longitude + '\'' +
                    ", latitude='" + latitude + '\'' +
                    ", contact='" + contact + '\'' +
                    ", consumption='" + consumption + '\'' +
                    ", created_at='" + created_at + '\'' +
                    ", updated_at='" + updated_at + '\'' +
                    ", nickname='" + nickname + '\'' +
                    ", cover='" + cover + '\'' +
                    '}';
        }
    }

    public static class Purchase implements Serializable {

        private String id;
        private String user_id;
        private String post_id;
        private int status;
        private String created_at;
        private String updated_at;
        private boolean isSel;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getUser_id() {
            return user_id;
        }

        public void setUser_id(String user_id) {
            this.user_id = user_id;
        }

        public String getPost_id() {
            return post_id;
        }

        public void setPost_id(String post_id) {
            this.post_id = post_id;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public String getCreated_at() {
            return created_at;
        }

        public void setCreated_at(String created_at) {
            this.created_at = created_at;
        }

        public String getUpdated_at() {
            return updated_at;
        }

        public void setUpdated_at(String updated_at) {
            this.updated_at = updated_at;
        }

        public boolean isSel() {
            return isSel;
        }

        public void setSel(boolean sel) {
            isSel = sel;
        }


        @Override
        public String toString() {
            return "Purchase{" +
                    "id=" + id +
                    ", user_id=" + user_id +
                    ", post_id=" + post_id +
                    ", status=" + status +
                    ", created_at='" + created_at + '\'' +
                    ", updated_at='" + updated_at + '\'' +
                    '}';
        }
    }

    public static class RepostPurchase implements Serializable {

        private String id;
        private String user_id;
        private String post_id;
        private int status;
        private String created_at;
        private String updated_at;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getUser_id() {
            return user_id;
        }

        public void setUser_id(String user_id) {
            this.user_id = user_id;
        }

        public String getPost_id() {
            return post_id;
        }

        public void setPost_id(String post_id) {
            this.post_id = post_id;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public String getCreated_at() {
            return created_at;
        }

        public void setCreated_at(String created_at) {
            this.created_at = created_at;
        }

        public String getUpdated_at() {
            return updated_at;
        }

        public void setUpdated_at(String updated_at) {
            this.updated_at = updated_at;
        }

        @Override
        public String toString() {
            return "RepostPurchase{" +
                    "id='" + id + '\'' +
                    ", user_id='" + user_id + '\'' +
                    ", post_id='" + post_id + '\'' +
                    ", status=" + status +
                    ", created_at='" + created_at + '\'' +
                    ", updated_at='" + updated_at + '\'' +
                    '}';
        }
    }

    public static class Statistic implements Serializable {

        private String post_id;
        private String repost;
        private String comment;
        private String praise;
        private String shared;
        private String view;

        public String getPost_id() {
            return post_id;
        }

        public void setPost_id(String post_id) {
            this.post_id = post_id;
        }

        public String getRepost() {
            return repost;
        }

        public void setRepost(String repost) {
            this.repost = repost;
        }

        public String getComment() {
            return comment;
        }

        public void setComment(String comment) {
            this.comment = comment;
        }

        public String getPraise() {
            return praise;
        }

        public void setPraise(String praise) {
            this.praise = praise;
        }

        public String getShared() {
            return shared;
        }

        public void setShared(String shared) {
            this.shared = shared;
        }

        public String getView() {
            return view;
        }

        public void setView(String view) {
            this.view = view;
        }

        public void addShared() {
            int newShared = Integer.parseInt(getShared());
            setShared((newShared + 1) + "");
        }

        public void addRePost() {
            int newRePost = Integer.parseInt(getRepost());
            setRepost((newRePost + 1) + "");
        }

        public void addComment() {
            int newComment = Integer.parseInt(getComment());
            setComment((newComment + 1) + "");
        }

        public void subComment() {
            int newComment = Integer.parseInt(getComment());
            setComment((newComment - 1) + "");
        }

        @Override
        public String toString() {
            return "Statistic{" +
                    "post_id='" + post_id + '\'' +
                    ", repost='" + repost + '\'' +
                    ", comment='" + comment + '\'' +
                    ", praise='" + praise + '\'' +
                    ", shared='" + shared + '\'' +
                    ", view='" + view + '\'' +
                    '}';
        }
    }
}